#ifndef ZORFCSADAPTER_H
#define ZORFCSADAPTER_H

#include <visibility.h>
#include <common/Runnable.h>
#include <common/Semaphore.h>

struct zorfcs_request_s;

namespace zorfcsadapter {

struct Param {
	int index;
	float value;
};

struct Wpt {
	int index;
	double lat;
	double lon;
	float alt;
};

struct BaroSetup {
	float pressure;
	float temp;
};

class ZorFcsAdapter : public Runnable {
public:
	ZorFcsAdapter();
	virtual ~ZorFcsAdapter();
private:
	virtual void run();
	void processRequest(const zorfcs_request_s &r);
	void processCommand(int cmd);
	void processReadParam(Param *param);
	void processWriteParam(const Param *param);
	void processReadWpt(Wpt *wpt);
	void processWriteWpt(const Wpt *wpt);
	void processSetActiveWpt(int index);
	void processSetOperWpt(const Wpt *wpt);
	void processSetADS(const BaroSetup *baroSetup);
	void processResetADS();
};

}

struct __EXPORT Request {
	Request(Semaphore &semaphore, void *data) : semaphore_(semaphore), data_(data) {}

	void * getData() {
		return data_;
	}

	void release() {
		semaphore_.give();
	}

private:
	Request();
	Semaphore &semaphore_;
	void *data_;
};

#endif

